package gui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class AccDeposit extends JPanel{
	
	private JLabel lbl_Header;
	private JLabel lbl_Intro;
	private JButton btn_Back;
	private JButton btn_Deposit;
	private JTextField textField_Deposit;
	private JTextField textField_CurrentBalance;
	private JLabel lbl_CurrentBalance;
	
	private double depositAmount;
	
	public AccDeposit() {
		
		setPreferredSize(new Dimension(550, 400));
		setLayout(null);
		
		lbl_Header = new JLabel("Account Deposit");
		lbl_Header.setFont(new Font("SansSerif", Font.BOLD, 26));
		lbl_Header.setBounds(200, 40, 207, 34);
		add(lbl_Header);
		
		lbl_Intro = new JLabel("<html><p>Please enter the amount <br> you want to deposit: </p></html>");
		lbl_Intro.setFont(new Font("SansSerif", Font.BOLD, 16));
		lbl_Intro.setBounds(200, 182, 211, 47);
		add(lbl_Intro);
		
		btn_Back = new JButton("Back");
		btn_Back.setFont(new Font("SansSerif", Font.PLAIN, 16));
		btn_Back.setBounds(59, 311, 100, 40);
		add(btn_Back);
		
		btn_Deposit = new JButton("Deposit!");
		btn_Deposit.setFont(new Font("SansSerif", Font.PLAIN, 16));
		btn_Deposit.setBounds(420, 311, 100, 40);
		add(btn_Deposit);
		
		textField_Deposit = new JTextField();
		textField_Deposit.setFont(new Font("SansSerif", Font.PLAIN, 16));
		textField_Deposit.setBounds(200, 230, 160, 30);
		add(textField_Deposit);
		textField_Deposit.setColumns(10);
		
		textField_CurrentBalance = new JTextField();
		textField_CurrentBalance.setHorizontalAlignment(SwingConstants.CENTER);
		textField_CurrentBalance.setEditable(false);
		textField_CurrentBalance.setFont(new Font("SansSerif", Font.BOLD | Font.ITALIC, 16));
		textField_CurrentBalance.setBounds(200, 141, 160, 30);
		add(textField_CurrentBalance);
		textField_CurrentBalance.setColumns(10);
		
		lbl_CurrentBalance = new JLabel("Current Balance:");
		lbl_CurrentBalance.setFont(new Font("SansSerif", Font.BOLD, 16));
		lbl_CurrentBalance.setBounds(200, 116, 130, 21);
		add(lbl_CurrentBalance);
	}
	
	public void addActionListener(ActionListener e){
		btn_Back.addActionListener(e);
		btn_Deposit.addActionListener(e);
	}
	
	public void clearField() {
		textField_Deposit.setText("");
		depositAmount = 0;
	}
	
	public void showField(double totalBalance){
		textField_CurrentBalance.setText("" + totalBalance);
	}
	
	public JButton getBack(){
		return btn_Back;
	}
	
	public JButton getBtnDeposit(){
		return btn_Deposit;
	}
	
	public double getInputDepositAmount() {
		depositAmount = Double.parseDouble(textField_Deposit.getText().trim());
		return depositAmount;
	}
	
}
